<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>角色列表</title>
    <#include "/view/admin/headList.html"/>

    <script src="${base}/jstool/artDialog/lib/sea.js"></script>
    <script>
        seajs.config({
            alias: {
                "jquery": "${base}/jstool/artDialog/lib/jquery-1.10.2.js"
            }
        });
    </script>

    <script>
        seajs.use(['jquery', '${base}/jstool/artDialog/src/dialog.js'], function ($, dialog) {


            //关联用户
            $('button[data-event=adduser]').on('click', function () {
                this.disabled="disabled";
                var roleId = $(this).attr('id').substring(2);
                var myDialog = dialog({
//                    follow:this,
                    fixed: true,
                    lock: true,
                    okValue: '确 定',
                    ok: function () {

                        setcode();
                        $('#a_'+roleId).removeAttr("disabled");
                        return true;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                        $('#a_'+roleId).removeAttr("disabled");
                    }
//                    cancelValue: '取消'
//                    follow: document.getElementById('followTestBtn'),
                });// 初始化一个带有loading图标的空对话框

                jQuery.ajax({
                    url: '${base}/xyrole/updateuser.do?roleId='+roleId,
                    success: function (data) {

//                        alert(1);
//                        myDialog.title('');
                        myDialog.content(data);// 填充对话框内容
//                        myDialog.lock();
//                        myDialog.__follow(this);
                       /* myDialog.button({
                            name: '登录',
                            focus: true,
                            callback: function () {}
                        }, {
                            name: '取消',
                            callback: function () {alert('取消');myDialog.close();}
                        })*/
                        myDialog.show();
                    }
                });
            });
                //角色授权
                $('button[data-event=updatepermission]').on('click', function () {
                this.disabled="disabled";
                var roleId = $(this).attr('id').substring(2);
                var myDialog = dialog({
//                    follow:this,
                    fixed: true,
                    lock: true,
//                    background:'#000',
                    okValue: '确 定',
                    ok: function () {

                        setcode();
                        $('#p_'+roleId).removeAttr("disabled");
                        return true;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                        $('#p_'+roleId).removeAttr("disabled");
                    }
                });// 初始化一个带有loading图标的空对话框

                jQuery.ajax({
                    url: '${base}/xypermission/updatepermission.do?roleId='+roleId,
                    success: function (data) {
                        myDialog.content(data);// 填充对话框内容
                        myDialog.show();
                    }
                });
            });


        });
    </script>
</head>
<body>

<div class="table-class">




    <table class="table table-hover table-list table-bordered">
        <thead>
        <tr >
            <td class="table-head-btn">
                <div style="text-align:left;margin-left: 50px;">
                    <a href="${base}/xyrole/add.do" class="btn btn-primary">新增</a>
                </div>
            </td>
        </tr>

        <tr class="table-head">
            <th>序号</th>
                <th class="label-hidden">角色ID</th>
                <th>角色名</th>

            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <#list pagination.list as c>
            <tr>
                <td>${(pagination.pageNo-1)*pagination.pageSize+1+c_index}</td>
                        <td class="label-hidden">${c.roleId!}</td>
                            <td>${c.name!}</td>


                <td>
                    <@shiro.hasPermission name="2.2.1">
                    <button data-event="adduser" id="a_${c.roleId!}"  class="btn btn-primary">关联用户</button>
                    </@shiro.hasPermission> 
                    <@shiro.hasPermission name="2.2.2">
                    <button data-event="updatepermission" id="p_${c.roleId!}"  class="btn btn-primary">角色授权</button>
                    </@shiro.hasPermission> 
                    <!--<a href="${base}/xyrole/detail.do?roleId=${c.roleId!}" class="btn btn-primary">详情</a>-->
                    <@shiro.hasPermission name="2.2.3">
                    <a href="${base}/xyrole/add.do?roleId=${c.roleId!}" class="btn btn-primary">修改</a>
                    </@shiro.hasPermission> 
                    <@shiro.hasPermission name="2.2.4">
                    <a href="javascript:checkDelete('${base}/xyrole/delete.do?roleId=${c.roleId!}')" class="btn btn-primary">删除</a>
                    </@shiro.hasPermission> 
                </td>
            </tr>


        </#list>






        </tbody>
    </table>


</div>
<script>
    function queryCondition(){
        return "code=";
    }

</script>

</body>
</html>
